package com.example.controller.institutioncare.peoplemanagement;


import com.example.utils.Results;
import com.qiniu.util.Auth;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

import java.util.UUID;

@CrossOrigin
@RestController
@Api(tags = "获取上传token")
@RequestMapping("/uuzi")
public class Abcd {


    @ApiOperation(value = "获得token",notes = "养老系统登录")
    @GetMapping("/getToken/{buname}")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "buname",//name
                    value = "buname",//参数的描述buname 空间名
                    required = true,//是否必须传入
                    //paramType定义参数传递类型：有path,query,body,form,header
                    paramType = "path"
            )
    })
    public Results getbyid(@PathVariable String buname){

        System.err.println(buname+"得到的空间名");
        String accessKey = "-l6IG_srmGe32h3-IFjbvzgVVHejMzfjA6yvelCv"; //你自己的key
        String secretKey = "N0lPSCU70-JiK36gV6HVctmOi_aYknd0L-g_v7qd"; //你自己的密钥
        Auth auth = Auth.create(accessKey,secretKey);
        UUID m = UUID.randomUUID();
        System.out.println(m);
        String fname = "test"+m;
        String token = auth.uploadToken("awdawdawsefgwse",fname); //你自己空间的名称
        System.out.println(token);
        return new Results().code(1001).data("token",token).data("fname",fname);
    }

}
